home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 23 / AACD 23.iso / AACD / Online / opennap / extrasocket.h < prev    next >
C/C++ Source or Header  |  2001-06-08  |  2KB  |  95 lines

  1. /* Copyright (C) 2001 jay@realfantasy.demon.co.uk
  2.    This is free software distributed under the terms of the
  3.    GNU Public License.  See the file COPYING for details. */
  4.  
  5. /* Additional inlines for opennap-0.41 to allow bsdsocket.library access to
  6.    a few functions not emulated by ixemul */
  7.  
  8. #ifndef _CDEFS_H_
  9. #include <sys/cdefs.h>
  10. #endif
  11.  
  12. __BEGIN_DECLS
  13.  
  14. #ifndef BASE_EXT_DECL
  15. #define BASE_EXT_DECL
  16. #define BASE_EXT_DECL0 extern struct Library * SocketBase;
  17. #endif
  18. #ifndef BASE_PAR_DECL
  19. #define BASE_PAR_DECL
  20. #define BASE_PAR_DECL0 void
  21. #endif
  22. #ifndef BASE_NAME
  23. #define BASE_NAME SocketBase
  24. #endif
  25.  
  26. BASE_EXT_DECL0
  27.  
  28. extern __inline char *
  29. Inet_NtoA (BASE_PAR_DECL unsigned long in)
  30. {
  31.     BASE_EXT_DECL
  32.     register char * res __asm("d0");
  33.     register struct Library *a6 __asm("a6") = BASE_NAME;
  34.     register unsigned long d0 __asm("d0") = in;
  35.     __asm __volatile ("jsr a6@(-0xae)"
  36.     : "=r" (res)
  37.     : "r" (a6), "r" (d0)
  38.     : "d0", "d1", "a0", "a1");
  39.     return res;
  40. }
  41. extern __inline struct hostent  *
  42. gethostbyname (BASE_PAR_DECL char * name)
  43. {
  44.     BASE_EXT_DECL
  45.     register struct hostent * res __asm("d0");
  46.     register struct Library *a6 __asm("a6") = BASE_NAME;
  47.     register char * a0 __asm("a0") = name;
  48.     __asm __volatile ("jsr a6@(-0xd2)"
  49.     : "=r" (res)
  50.     : "r" (a6), "r" (a0)
  51.     : "d0", "d1", "a0", "a1");
  52.     return res;
  53. }
  54. extern __inline unsigned long
  55. inet_addr (BASE_PAR_DECL const char * cp)
  56. {
  57.     BASE_EXT_DECL
  58.     register res __asm("d0");
  59.     register struct Library *a6 __asm("a6") = BASE_NAME;
  60.     register const char * a0 __asm("a0") = cp;
  61.     __asm __volatile ("jsr a6@(-0xb4)"
  62.     : "=r" (res)
  63.     : "r" (a6), "r" (a0)
  64.     : "d0", "d1", "a0", "a1");
  65.     return res;
  66. }
  67.  
  68. extern __inline char * 
  69.   inet_ntoa(BASE_PAR_DECL struct in_addr addr) 
  70. {
  71.   return Inet_NtoA(addr.s_addr);
  72. }
  73.  
  74. extern __inline void
  75. vsyslog (BASE_PAR_DECL int level, const char * format, va_list ap)
  76. {
  77.     BASE_EXT_DECL
  78.     register struct Library *a6 __asm("a6") = BASE_NAME;
  79.     register unsigned long d0 __asm("d0") = level;
  80.     register const char * a0 __asm("a0") = format;
  81.     register long * a1 __asm("a1") = ap;
  82.     __asm __volatile ("jsr a6@(-0x102)"
  83.     : /* No Output */
  84.     : "r" (a6), "r" (d0), "r" (a0), "r" (a1)
  85.     : "d0", "d1", "a0", "a1");
  86. }
  87.  
  88. #undef BASE_EXT_DECL
  89. #undef BASE_EXT_DECL0
  90. #undef BASE_PAR_DECL
  91. #undef BASE_PAR_DECL0
  92. #undef BASE_NAME
  93.  
  94. __END_DECLS
  95.